package com.si.rapid;

import com.si.rapid.SearchListActivity;
import com.si.rapid.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
/**
 * A class to control the main window of the application
 * @author Carlos Martinez
 *
 */
public class RapidSearch extends Activity {


    private Button buttonSearch;
	private Button buttonQuit;
	
	private EditText editTextSearch;
	
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        editTextSearch = (EditText) findViewById(R.id.CuadroBusqueda);
        
        buttonSearch = (Button) findViewById(R.id.SearchButton);
		buttonSearch.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				startSearch();
			}
		});
		
		 buttonQuit = (Button) findViewById(R.id.QuitButton);
			buttonQuit.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
					try {
						System.exit(0);
					} catch (Throwable e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			});
        
    }
    
	private void startSearch() {
		// start activity for list of accounts
		Intent i = new Intent(this, SearchListActivity.class);
		i.putExtra("Search", editTextSearch.getText().toString());
		startActivity(i);
	}

}